// -----------------------------------------------------------------------------
// defaulte values 
// -----------------------------------------------------------------------------
var _id = 0;
var _top05 = new Array(5); // top05
var _top10 = new Array(10); // top10
var g_numcolor = [0,1,1,2,2,3,3,1,1,2,2,3,1,1,2,2,3,3,1,1,2,3,3,1,1,2,2,3,3,1,1,2,3,3,1,1,2,2,3,3,1,2,2,3,3,1,1,2,2,3];
var colors = ["","red", "blue", "green"];
var bo1_num = 0;
var bo2_num = 0;
var split = 1;

var timer_id;
var _timer = 30000;

// set the quick button
var btn0_choice = 11;
var btn1_choice = 0.5;


// -----------------------------------------------------------------------------
// even functions, ajax function
// -----------------------------------------------------------------------------

$("input#btnReflash").click(function(){
  var splitv = $('#split').val(); 
  var orderv = $('#norder').val();
  // $("input").attr("disabled", "disabled");
  // window.open("op.php?fp=xmlBetTotal_6h&playtype=" + myGlobalVal.playtypestr + "&id="+myGlobalVal.lotto_id + "&slc=" + myGlobalVal.slc + "&norder=" + orderv + "&split=" + splitv + "&subtype=" + myGlobalVal.subtype);
  // return;
  $.ajax({
    url: "op.php?op=centralize&fp=xmlBetTotal_6h"
    , data: {playtype : myGlobalVal.playtypestr, id : myGlobalVal.lotto_id, slc : myGlobalVal.slc, cid : myGlobalVal.cid
             , split : splitv, norder : orderv, subtype : myGlobalVal.subtype}
    , type: "GET"
    , dataType: "json"
    , success: function(rdata) {
        if( rdata == undefined){ $("#myDivTbl").showErr('资料得异常! 请检查期数、赔率与累计资料表是否正确存在!'); return; }
        if( rdata.rchk != 1){ $("#myDivTbl").showErr('查无相关资料,请检查期数、赔率与累计资料表是否正确存在!'); return; }
        switch( myGlobalVal.playtypestr ){
          case 'now1': gen_now1(rdata); break;
          case 'now1_1': gen_now1_1(rdata); break;
          case 'now2': gen_now2(rdata); break;
          case 'now4': gen_now4(rdata); break;
          case 'now3': gen_now3(rdata); break;
          case 'now5': gen_now5(rdata); break;
          case 'now8': gen_now8(rdata); break;
          case 'now6': gen_now6(rdata); break;
          case 'now7': gen_now7(rdata); break;
          case 'now9': gen_now9(rdata); break;
          default: $("#myDivTbl").html('error!'); break;
        }
      
      // $("input").removeAttr("disabled");
    }
    , error: function(){
      $("#myDivTbl").showErr('资料取得失败！ 请按 F5 重新整理页面后再查看。');
    }
  });

});

// show the error msg
$.fn.showErr = function(msg){
  $(this).html('<div class="msgBox-Now" style="width:990px;font-size:16px;">'+ msg +'</div>');
}

// change rate function
// btp, bettype or one of key character, a key character means quick change rate
function ratediffChg(btp, subbtp, nums, rate){
  //var btn0_choice = 11;
  // send the rate change data to xmlSetRate_6h to change rate
                                  
  rate = rate * myGlobalVal.addRate;
  var uu = "op.php?fp=xmlSetRate_6h&id="+myGlobalVal.lotto_id+"&bettype=" + btp + "&number=" + nums +"&rate=" + rate + "&pagename=" + myGlobalVal.playtypestr + "&method=1&cid=" + myGlobalVal.cid + "&subtype=" + myGlobalVal.subtype + "&btn0_choice=" + btn0_choice;
  if(btn0_choice == '21' ){
    uu = uu + "&top10=" + _top10.join(",");
  }else if(btn0_choice == '24' ){
    uu = uu + "&top5=" + _top05.join(",");
  }
  // window.open(uu);
  // return true;
  $.ajax({
    type: 'POST',
    url: uu,
    dataType: 'json',
    success: function(rdata){
      if( rdata.msg != undefined && rdata.msg == "OK" ){
         if(( btp == 27 || btp == 36) && myGlobalVal.subtype > 0){
           showRateTbl( btp, myGlobalVal.subtype );
           
         }else{
           $("#btnReflash").click();
         }
         
      }else{
        alert('error!');
      }
    }
  });
	 
  
  return true;
}

// open the little rate table
function showRateTbl(bettype, subid){

  var oObj = document.getElementById("divRatePanel");
  var str = "";
  var sTitle, sArr;
  bettype = bettype + "";
  switch(bettype){
    case '27': 
      sTitle = "连肖";
      sArr = new Array();
      sArr[2] = "二肖 "; 
      sArr[3] = "三肖 ";
      sArr[4] = "四肖 ";
      sArr[5] = "五肖 ";
      break;   
      
    case '36':
      sTitle = "连尾";
      sArr = new Array();
      sArr[21] = "二尾 中";
      sArr[22] = "二尾不中";
      sArr[31] = "三尾 中";
      sArr[32] = "三尾不中";
      sArr[41] = "四尾 中";
      sArr[42] = "四尾不中"; 
      break;
      
    default:
      oObj.innerHTML = "<div>showRateTbl ERROR :: BETTYPE ERROR! - [" + bettype + "] </div>";
      return 'error bettype';
      break;
      
  }
  
  var splitv = $('#split').val(); 
  var orderv = $('#norder').val();   
  if(myGlobalVal.subtype != subid){
    oObj.innerHTML = "<div>赔率载入中...请稍候...</div>";
    $("div#divRatePanel").css({'top': event.clientY + 10 , 'left':event.clientX + 10, 'height': '220px' }) ;
  }      
  oObj.className = "showRateRecord";
  
  myGlobalVal.subtype = subid;
  //window.open("op.php?fp=xmlBetTotal_6h&playtype=" + myGlobalVal.playtypestr + "&id="+myGlobalVal.lotto_id + "&slc=" + myGlobalVal.slc + "&norder=" + orderv + "&split=" + splitv + "&subtype=" + myGlobalVal.subtype);
  // return;
  $.ajax({
    url: "op.php?op=centralize&fp=xmlBetTotal_6h"
    , data: {playtype : myGlobalVal.playtypestr, id : myGlobalVal.lotto_id, slc : myGlobalVal.slc, cid : myGlobalVal.cid
             , split : splitv, norder : orderv, subtype : myGlobalVal.subtype}
    , type: "GET"
    , dataType: "json"
    , success: function(rdata) {
        if( rdata == undefined){ $("#myDivTbl").showErr('资料得异常! 请检查期数、赔率与累计资料表是否正确存在!'); return false; }
        if( rdata.rchk != 1){ $("#myDivTbl").showErr('查无相关资料,请检查期数、赔率与累计资料表是否正确存在!'); return false; }
          str = "<div class='td0' align=right><span style='float:left;padding-top:5px;'> " + sTitle + "操盘赔率设定【" + sArr[subid] + "】</span><input type='button' value='&nbsp;X&nbsp;' onclick='javascript:divRatePanel_close();' class='c4'></div>";
          str += crtTbl_0to9( bettype, subid, rdata);
          str += "<br />"; 
          str += "<div id='div0AddVal'>" + crt_divBtnAddVal(0,0) + "</div>";
          oObj.innerHTML = str; 
          
    }
    , error: function(){
      $("#myDivTbl").showErr('资料取得失败！ 请重新整理页面后再查看。');
    }
  });
}

//关闭赔率设定表
function divRatePanel_close(){
  var oObj = document.getElementById("divRatePanel");
  oObj.innerHTML = "";
  oObj.className= "noneRateRecord";
}


function bo()
{
	SetCookie("bo1", $('#bo1').val());
	SetCookie("bo2", $('#bo2').val());
	bo1_num = document.all.bo1.value - 0;
	bo2_num = document.all.bo2.value - 0;
	$("input#btnReflash").click();
}

// change of the quick key word
function chsbtn(oObj, qtype){
  $('#div0Quick span.btnchoiced').removeClass('btnchoiced').addClass('btnchoice');
  $(oObj).removeClass('btnchoice').addClass('btnchoiced');
  btn0_choice = qtype;
  return true;
}

function chsRateAddVal(oObj, btnSpan){
  btnSpan.removeClass('btnchoiced').addClass('btnchoice');
  $(oObj).removeClass('btnchoice').addClass('btnchoiced');
  btn1_choice = $(oObj).text();
  return true;
}

function chgRateBtn(oThis, chgRate){
  $('#divBtnAddVal span.btnchoiced').removeClass('btnchoiced').addClass('btnchoice');
  $(oThis).addClass('btnchoiced');
  if($(oThis).text() == chgRate){
    myGlobalVal.addRate = chgRate;
    return true;
  }else{
    alert('请重新点选!');
    return false;
  }
}

// -----------------------------------------------------------------------------
// print rate data and table functions
// ----------------------------------------------------------------------------

// TYPE A. create 1 - 49 numbers table
// -----------------------------------
function crtTbl_1to49( bettype, boFlag, rdata, rdataTotal ){
	var i, oObj, ret, str, num, winlostclass;
  var dataLen = rdata.length;
  var iNumTr = 10;
  var trArr = new Array();
  for(i = 0; i < iNumTr; i++){ trArr[i] = '';}
  if(bettype > 9990){
    for(i = 0; i < dataLen; i++){
      idx = i % iNumTr;
      oObj = rdata[i];
      num = oObj.numbers - 0;
      if(i < 10){ _top10[i] = oObj.numbers; }
      if(i < 5){ _top05[i] = oObj.numbers; }
      winlostclass = ( oObj.winlost < 0 ? "lost" : "win" );
      trArr[idx] += "<td class='td1" + colors[g_numcolor[num]] + "' style='background-color:#fff9b6'>" + oObj.numbers + "</td>";
      trArr[idx] += "<td class='" + winlostclass + "' nowrap >" + oObj.winlost + "</td>";
      trArr[idx] += "<td class='rate'>" + oObj.rate + "</td>";
      trArr[idx] += "<td>";                                
      trArr[idx] += "<input type=button onclick=\"javascript:ratediffChg('" + bettype + "',0,'" + oObj.numbers + "', -1);\" value='-' class='btnmin'>&nbsp;";
      trArr[idx] += "<input type=button onclick=\"javascript:ratediffChg('" + bettype + "',0,'" + oObj.numbers + "', 1);\" value='+' class='btnplus'>";
      trArr[idx] += "</td>";
    }
    var cSpan = 4;
    var sTitle = "<td nowrap>号码</td><td nowrap>预估输赢</td><td nowrap>赔率</td><td nowrap>操盘</td>";
  
  }else{
    var subid = 0;
    if( boFlag ){ subid = boFlag; }
    for(i = 0; i < dataLen; i++){
      idx = i % iNumTr;
      oObj = rdata[i];
      num = oObj.numbers - 0;
      winlostclass = ( oObj.winlost < 0 ? "lost" : "win" );
      if(i < 10){ _top10[i] = oObj.numbers; }
      if(i < 5){ _top05[i] = oObj.numbers; }
      trArr[idx] += "<td class='td1" + colors[g_numcolor[num]] + "'>" + oObj.numbers + "</td>";
      trArr[idx] += "<td>" + oObj.amount + "</td>";
      trArr[idx] += "<td class='" + winlostclass + "' nowrap >" + oObj.winlost + "</td>";
      if( boFlag ){ trArr[idx] += "<td>&nbsp;</td>"; }
      trArr[idx] += "<td class='rate'>" + oObj.rate + "</td>";
      trArr[idx] += "<td>";
      trArr[idx] += "<input type=button onclick=\"javascript:ratediffChg('" + bettype + "'," + subid + ",'" + oObj.numbers + "', -1);\" value='-' class='btnmin'>&nbsp;";
      trArr[idx] += "<input type=button onclick=\"javascript:ratediffChg('" + bettype + "'," + subid + ",'" + oObj.numbers + "', 1);\" value='+' class='btnplus'>";
      trArr[idx] += "</td>";
    }
  
    if( boFlag ){ var sTitle = "<td nowrap>号码</td><td nowrap>金额</td><td nowrap>输赢</td><td nowrap>补货</td><td nowrap>赔率</td><td nowrap>操盘</td>"; }
    else{ var sTitle = "<td nowrap>号码</td><td nowrap>金额</td><td nowrap>输赢</td><td nowrap>赔率</td><td nowrap>操盘</td>"; }
    if( boFlag ){ var cSpan = 6; }else{  var cSpan = 5; }
  } 
  
  ret = "<table width='990' class='tblMy6H'>";
	ret += "<tr class='td0' align='center'>";
  for (i = 0; i < 5; i++){ ret += sTitle; }
  ret += "</tr>";
  str = ret + "<tr class=td2 align=right>" + trArr.join("</tr><tr class=td2 align=right>");
  
  str += "<td colspan='" + cSpan + "'>合计: " + rdataTotal.amount + "</td>";
  str += "</tr></table>";
  return str;
}

// TYPE B. create two face , show as Verital one item each row
// -----------------------------------------------------------
function crtTbl_1itmVrt(bettype, subtype, subTitle, rTitle, rdata, rdataTotal ){
  var str = "";
  var oObj, winlostclass;
  str  = "<table width='100%' class='tblMy6H'>";
  str += "<tr class='td0' align=center><td nowrap>" + subTitle + "</td><td nowrap>金额</td><td nowrap>输赢</td><td nowrap>赔率</td><td nowrap>操盘</td></tr>";
  for(var i = 0; i < rdata.length; i++){
    oObj = rdata[i];
    winlostclass = ( oObj.winlost < 0 ? "lost" : "win" );
    str += "<tr class='td2' align='right'>";
    str += "<td align='center' class=td15>" + rTitle[i] + "</td>";
    str += "<td>" + oObj.amount + "</td>";
    str += "<td class='" + winlostclass + "' nowrap >" + oObj.winlost + "</td>";
    str += "<td class='rate'>" + oObj.rate + "</td>";
    str += "<td>";
    str += "<input type=button onclick=\"javascript:ratediffChg('" + bettype + "', '" + subtype + "', '" + oObj.numbers + "', -1);\" value='-' class='btnmin'>&nbsp;";
    str += "<input type=button onclick=\"javascript:ratediffChg('" + bettype + "', '" + subtype + "', '" + oObj.numbers + "', 1);\" value='+' class='btnplus'>";
    str += "</td>";
    str += "</tr>";
  }
  str += "<tr class='td6' align='right'><td class='td0'>合计 </td><td>" + rdataTotal.amount + "</td><td></td><td></td><td></td></tr>";
  //str += "</tr>";
  str += "</table>";
  return str;

}

// TYPE C. creare lot items, show as Verital two item each row
// -----------------------------------------------------------
function crtTbl_2itmVrt( bettype, subtype, subTitle, rTitle, rdata, rdataTotal ){ 
  var str = "";
  var oObj, winlostclass;
  str  = "<table width='100%' class='tblMy6H'>";
  str += "<tr class='td0' align='center'><td nowrap>" + subTitle + "</td><td nowrap>金额</td><td nowrap>输赢</td><td nowrap>赔率</td><td nowrap>操盘</td>";
  str += "<td nowrap>" + subTitle + "</td><td nowrap>金额</td><td nowrap>输赢</td><td nowrap>赔率</td><td nowrap>操盘</td></tr>";
  str += "<tr class='td2' align='right'>";
  for(var i = 0; i < rdata.length; i++){
    if( i > 0 && i % 2 == 0) { str += "</tr><tr class='td2' align='right'>";}
    oObj = rdata[i];
    winlostclass = ( oObj.winlost < 0 ? "lost" : "win" );
    str += "<td align='center' class='td6'>" + rTitle[i] + "</td>";
    str += "<td>" + oObj.amount + "</td>";
    str += "<td class='" + winlostclass + "' nowrap >" + oObj.winlost + "</td>";
    str += "<td class='rate'>" + oObj.rate + "</td>";
    str += "<td>";                                  
    str += "<input type=button onclick=\"javascript:ratediffChg('" + bettype + "','" + subtype + "', '" + oObj.numbers + "', -1);\" value='-' class='btnmin'>&nbsp;";
    str += "<input type=button onclick=\"javascript:ratediffChg('" + bettype + "','" + subtype + "', '" + oObj.numbers + "', 1);\" value='+' class='btnplus'>";
    str += "</td>";
    
  }
  str += "</tr>";
  str += "<tr class='td6'><td class='td2'  colspan='10'>合计: " + rdataTotal.amount + "</td></tr>";
  str += "</table>";
  return str;

}

// TYPE D. create two face, from 1 to 6 in special bettype 
// -----------------------------------------------------------
function crtTbl_2Cen6Spe( bettype, subtype, subTitle, rTitle, rdata, rdataTotal ){
  var orderArr = ['正码一', '正码二', '正码三', '正码四','正码五','正码六'];
  var tl = rTitle.length; 
  var i, j, q, oObj, titIdx;
  var st1 = "";
  var st2 = "";
  var st3 = "";
  var litTotal = 0;
  st1 += "<td rowspan='2'>&nbsp;</td>"
  for(i = 0; i < tl; i++){
    st1 += "<td nowrap colspan='4'>" + rTitle[i] + "</td>";
    st2 += "<td nowrap>金额</td><td nowrap>输赢</td><td nowrap>赔率</td><td nowrap>操盘</td>";
  }
  st1 += "<td nowrap rowspan='2'>合计</td>";
                              
  for(var i = 0; i < rdata.length; i++){
    
    if(i == 0){ st3 = "<td class='td15' nowrap>" + orderArr[0] + "</td>"; }
    if( i > 0 && i % tl == 0) {titIdx = Math.floor(i / tl); st3 += "<td class='td6'>" + litTotal + "</td></tr><tr class='td2' align='right'><td class='td15' nowrap>" + orderArr[titIdx] + "</td>"; litTotal = 0;  }
    
    oObj = rdata[i];
    winlostclass = ( oObj.winlost < 0 ? "lost" : "win" );
    litTotal = oObj.amount - 0 + litTotal;
    
    st3 += "<td>" + oObj.amount + "</td>";
    st3 += "<td class='" + winlostclass + "' nowrap >" + oObj.winlost + "</td>";
    st3 += "<td class='rate'>" + oObj.rate + "</td>";
    st3 += "<td>";
    st3 += "<input type=button onclick=\"javascript:ratediffChg('" + bettype + "', '" + subtype + "', '" + oObj.numbers + "', -1);\" value='-' class='btnmin'>&nbsp;";
    st3 += "<input type=button onclick=\"javascript:ratediffChg('" + bettype + "', '" + subtype + "', '" + oObj.numbers + "', 1);\" value='+' class='btnplus'>";
    st3 += "</td>";
  }
  st3 += "<td class='td6'>" + litTotal + "</td>";
  var str  = "<table width='100%' class='tblMy6H'>";
  str  += "<tr class='td0' align='center'>" + st1 + "</tr>"; 
  str  += "<tr class='td1' align='center'>" + st2 + "</tr>";
  str  += "<tr class='td2' align='right'>" + st3 + "</tr>";
  str += "</table>";
  return str;
}

// TYPE E. create 1 - 49 ONLY numbers and Rate table, without winlost
// -----------------------------------
function crtTbl_1to49OnlyRate( bettype, iNum, rdata){
  
	var dataLen = rdata.length;
  var iNumTr = iNum;
  var trArr = new Array();
  var rRate, num, numshow;
  for(i = 0; i < iNumTr; i++){ trArr[i] = '';} 
  
  for(i = 0; i < dataLen; i++){
    
    if( i == 0 ){ idx = 0; }
    else{ idx = i % iNumTr; }
    
    rRate = rdata[i];
    
    num = i + 1
    numshow = num > 9 ? num : '0' + num; 
    trArr[idx] += "<td class='td1" + colors[g_numcolor[num]] + "'>" + numshow + "</td>";
    trArr[idx] += "<td class='rate'>" + rRate + "</td>";
    trArr[idx] += "<td align=left>";
    trArr[idx] += "<input type=button onclick=\"javascript:ratediffChg('" + bettype + "', 0, '" + num + "', -1);\" value='-' class='btnmin'>&nbsp;";
    trArr[idx] += "<input type=button onclick=\"javascript:ratediffChg('" + bettype + "', 0, '" + num + "', 1);\" value='+' class='btnplus'>";
    trArr[idx] += "</td>";
  }

  var sTitle = "<td nowrap>号码</td><td nowrap>赔率</td><td nowrap>操盘</td>";
  var sTitleNum = Math.ceil(i / iNum);
  ret = "<table width='990' class='tblMy6H'>";
	ret += "<tr class='td0' align='center'>";
  for (i = 0; i < sTitleNum; i++){ ret += sTitle; }
  ret += "</tr>";
  str = ret + "<tr class=td2 align=right>" + trArr.join("</tr><tr class=td2 align=right>") + "<td colspan='3'>&nbsp;</td></tr></table>";
  return str;
}

// TYPE F. create 1 - 10 numbers table
// -----------------------------------
function crtTbl_0to9( bettype, subid, rdataObj ){
  
  var trArr = new Array();
  var rRate, num, numshow, numArr;
  var iNumTr = 5;
  var addI = 0;
  var rdata = eval("rdataObj.rspe" + bettype + "_rateArr");
  bettype = bettype + ""; 
  switch(bettype){
    case '27': numArr = ["鼠","牛","虎","兔","龙","蛇","马","羊","猴","鸡","狗","猪"]; addI = 1; lstTitle = ""; iNumTr = 6;break;
    case '36': numArr = [0,1,2,3,4,5,6,7,8,9]; addI = 0; lstTitle = "尾"; iNumTr = 5; break;
    default: return 'error arrType'; break;
  }
  var dataLen = numArr.length;
  
  for(i = 0; i < iNumTr; i++){ trArr[i] = '';} 
  
  for(i = 0; i < dataLen; i++){
    
    if( i == 0 ){ idx = 0; }
    else{ idx = i % iNumTr; }
    
    rRate = rdata[i];
    
    num = i - 0 + addI;
    numshow = numArr[i] + lstTitle; 
    trArr[idx] += "<td class='td15'>" + numshow + "</td>";
    trArr[idx] += "<td class='rate'>" + rRate + "</td>";
    trArr[idx] += "<td align=left>";
    trArr[idx] += "<input type=button onclick=\"javascript:ratediffChg('" + bettype + "', " + subid + ", '" + num + "', -1);\" value='-' class='btnmin'>&nbsp;";
    trArr[idx] += "<input type=button onclick=\"javascript:ratediffChg('" + bettype + "', " + subid + ", '" + num + "', 1);\" value='+' class='btnplus'>";
    trArr[idx] += "</td>";
  }

  var sTitle = "<td nowrap>号码</td><td nowrap>赔率</td><td nowrap>操盘</td>";
  var sTitleNum = Math.ceil(i / iNumTr);
  ret = "<table width='280' class='tblMy6H'>";
	ret += "<tr class='td0' align='center'>";
  for (i = 0; i < sTitleNum; i++){ ret += sTitle; }
  ret += "</tr>";
  str = ret + "<tr class=td2 align=right>" + trArr.join("</tr><tr class=td2 align=right>") + "</tr></table>";
  return str;

}



// -----------------------------------------------------------------------------
// print quick buttons
// -----------------------------------------------------------------------------

// 增量 - 按钮 + -
function crt_divBtnAddVal(showAct, actFlag, betChar){
  var str = ""
  switch(showAct){
    case 0 :
      var btnArr = [5,4,3,2,1,0.5,0.4,0.3,0.2,0.1,0.05,0.03,0.01,0.005,0.001];
      break;
    case 1 :
      var btnArr = [20 ,15 ,10 ,5 ,1];
      break;
    case 2 :
      var btnArr = [1, 0.5, 0.3, 0.1, 0.05, 0.03, 0.01, 0.005, 0.001];
      break;  
    default:
      return "";
  }
  var btnStr = "";
  var defRateBtn = 0.001;
  for(var i = 0; i < btnArr.length; i++){
    if( btnArr[i] == defRateBtn ){
      btnStr += "<span class=btnchoiced onclick='javascript:chgRateBtn(this, " + btnArr[i] + ")'>" + btnArr[i] + "</span>";
    }else{
      btnStr += "<span class=btnchoice onclick='javascript:chgRateBtn(this, " + btnArr[i] + ")'>" + btnArr[i] + "</span>";
    }
  }
  
  str += "<div id='divBtnAddVal'>";
  if( actFlag == 0) { str += "增量&nbsp;"; }
  str += btnStr;
  if( actFlag == 1) { str += "　动作<input type='button' value='-' class='btnmin' onclick='javascript:ratediffChg(\"" + betChar + "\", 0, 0, -1);' />&nbsp;<input type='button' value='+' class='btnplus' onclick='javascript:ratediffChg(\"" + betChar + "\", 0, 0, 1);' />"; }
  str += "</div>";
  return str;
}

// 快选按钮
function crt_divBtnQuick(showAct){
  var str = "";
  var btnArr = [];
  var btnKey = [];
  switch(showAct){
    case 0:
      var btnArr = ["红"  ,"蓝"  ,"绿"  ,"单"  ,"双"  ,"大"  ,"小"  ,"合单"  ,"合双"  ,"家禽"  ,"野兽"  ,"特尾大"  ,"特尾小"  ,"合尾大"  ,"合尾小", "红单"  ,"红双"  ,"红大"  ,"红小"  ,"蓝单"  ,"蓝双"  ,"蓝大"  ,"蓝小"  ,"绿单"  ,"绿双"  ,"绿大"  ,"绿小"  ,"前10"  ,"前 5"  ,"全部"];
      var btnKey = [11 ,12 ,13 ,14 ,15 ,16 ,17 ,18 ,19 ,22 ,23 ,37 ,38 ,39 ,40 ,25  ,26  ,27  ,28  ,29  ,30  ,31  ,32  ,33  ,34  ,35  ,36  ,21  ,24  ,20];
      break;
    default:
      return "";
  }
  btn0_choice = btnKey[0];
  for(var i = 0; i < btnKey.length; i++){
    if( i > 0){ str += "<span class=btnchoice onclick='chsbtn(this, " + btnKey[i] + ")'>" + btnArr[i] + "</span>&nbsp;";}
    else{ str += "<span class=btnchoiced onclick='chsbtn(this, " + btnKey[i] + ")'>" + btnArr[i] + "</span>&nbsp;"; }
    
    if( i == 14 ){ str += "<br /><br />"; }
    
  }
  return str;
}


// -----------------------------------------------------------------------------
// functions of create tables 
// -----------------------------------------------------------------------------

function show_titleAmu(str)
{
	var a0 = str.split(",");
	var i = 0;
	var l = a0.length;
	var amu = 0;
	var clr = '';
	var oObj = '';
	for (i=0; i<l; i++) {
		a00 = a0[i].split("@");
		amu = a00[0];
		if(a00[1] > 0){ clr = '#ffff99';  }else{ clr = 'transparent';  }
    oObj = document.getElementById("menuAmu"+i);
    oObj.innerHTML = amu;
    oObj.style.backgroundColor = clr;
	}
}


function gen_now1(rdata){
  $('#div0').html(crtTbl_1to49( 0, 1, rdata.r1001, rdata.r1001total )); // 1001
  $('#div1').html(crtTbl_1itmVrt(1, "", "类别", ["特单","特双"], rdata.r1, rdata.r1total ));
  $('#div2').html(crtTbl_1itmVrt(2, "", "类别", ["特大","特小"], rdata.r2, rdata.r2total ));
  $('#div3').html(crtTbl_1itmVrt(3, "", "类别", ["合单","合双"], rdata.r3, rdata.r3total ));
  $('#div47').html(crtTbl_1itmVrt(47, "", "类别", ["合大","合小"], rdata.r47, rdata.r47total ));
  
  $('#div28').html(crtTbl_1itmVrt(28, "", "类别", ["特尾大","特尾小"], rdata.r28, rdata.r28total ));
  $('#div30').html(crtTbl_1itmVrt(30, "", "类别", ["合尾大","合尾小"], rdata.r30, rdata.r30total ));
  $('#div20').html(crtTbl_1itmVrt(20, "", "类别", ["家禽","野兽"], rdata.r20, rdata.r20total ));
  
  $('#div18').html(crtTbl_2itmVrt( 18, "", "半波", ["红单","红双","红大","红小","蓝单","蓝双","蓝大","蓝小","绿单","绿双","绿大","绿小"], rdata.r18, rdata.r18total ));
  $('#div14').html(crtTbl_2itmVrt( 14, "", "半波", ["鼠","牛","虎","兔","龙","蛇","马","羊","猴","鸡","狗","猪"], rdata.r14, rdata.r14total ));
  
  $('#div13').html(crtTbl_1itmVrt(13, "", "色波", ["红波","蓝波","绿波"], rdata.r13, rdata.r13total ));
  $('#div46').html(crtTbl_1itmVrt(46, "", "特大中小", ["大","中","小"], rdata.r46, rdata.r46total ));

}

function gen_now1_1(rdata){
  
    var namArr = ["中","不中"];
    $('#div19_01').html(crtTbl_1itmVrt(19, "01", "１肖", namArr, rdata.r19_01, rdata.r19_01total ));
    $('#div19_02').html(crtTbl_1itmVrt(19, "02", "２肖", namArr, rdata.r19_02, rdata.r19_02total ));
    $('#div19_03').html(crtTbl_1itmVrt(19, "03", "３肖", namArr, rdata.r19_03, rdata.r19_03total ));
    $('#div19_04').html(crtTbl_1itmVrt(19, "04", "４肖", namArr, rdata.r19_04, rdata.r19_04total ));
    $('#div19_05').html(crtTbl_1itmVrt(19, "05", "５肖", namArr, rdata.r19_05, rdata.r19_05total ));
    $('#div19_06').html(crtTbl_1itmVrt(19, "06", "６肖", namArr, rdata.r19_06, rdata.r19_06total ));
    $('#div19_07').html(crtTbl_1itmVrt(19, "07", "７肖", namArr, rdata.r19_07, rdata.r19_07total ));
    $('#div19_08').html(crtTbl_1itmVrt(19, "08", "８肖", namArr, rdata.r19_08, rdata.r19_08total ));
    $('#div19_09').html(crtTbl_1itmVrt(19, "09", "９肖", namArr, rdata.r19_09, rdata.r19_09total ));
    $('#div19_10').html(crtTbl_1itmVrt(19, "10", "10肖", namArr, rdata.r19_10, rdata.r19_10total ));
    $('#div19_11').html(crtTbl_1itmVrt(19, "11", "11肖", namArr, rdata.r19_11, rdata.r19_11total ));
}

function gen_now2(rdata){
  $('#div1002').html(crtTbl_1to49( 4, 1, rdata.r1002, rdata.r1002total ));  
  
  $('#div5').html(crtTbl_1itmVrt(5, "", "类别", ["总单","总双"], rdata.r5, rdata.r5total ));
  $('#div15').html(crtTbl_2Cen6Spe( 15, "", "", ["单","双"], rdata.r15, rdata.r15total ));
  $('#div16').html(crtTbl_2Cen6Spe( 16, "", "", ["大","小"], rdata.r16, rdata.r16total ));
  
  $('#div6').html(crtTbl_1itmVrt(6, "", "类别", ["总大","总小"], rdata.r6, rdata.r6total ));
  $('#div17').html(crtTbl_2Cen6Spe( 17, "", "", ["红波","蓝波","绿波"], rdata.r17, rdata.r17total ));
  $('#div23').html(crtTbl_2Cen6Spe( 23, "", "", ["合单","合双"], rdata.r23, rdata.r23total ));
}
function gen_now4(rdata){
  var rx = '';
  var rxt = '';
  switch(myGlobalVal.subtype){
    case 1: rx = rdata.r1003_1; rxt = rdata.r1003_1total; break;
    case 2: rx = rdata.r1003_2; rxt = rdata.r1003_2total; break;
    case 3: rx = rdata.r1003_3; rxt = rdata.r1003_3total; break;
    case 4: rx = rdata.r1003_4; rxt = rdata.r1003_4total; break;
    case 5: rx = rdata.r1003_5; rxt = rdata.r1003_5total; break;
    case 6: rx = rdata.r1003_6; rxt = rdata.r1003_6total; break;
    default: alert('error!'); return;
  }
  var orderArr = ['', '正码一', '正码二', '正码三', '正码四','正码五','正码六'];
  $('#div1003').html('<div class="td0" style="width:990px;text-align:center;padding:3px;">' + orderArr[myGlobalVal.subtype] + '</div>' + crtTbl_1to49( 25, myGlobalVal.subtype, rx, rxt ));
  
  var str = "[";
  for(var i = 1; i < 7; i++){
    if ( i > 1 ) str += "｜";
    if ( i == myGlobalVal.subtype ){ str +=  "<a href='javascript:setSubtype(" + i + ");' class='td0' style='text-align:center;padding:3px;text-decoration: none;'>" + orderArr[i] + "(0)</a>" ;}
    else{ str += "<a href='javascript:setSubtype(" + i + ");'>" + orderArr[i] + "(0)</a>"; }
  }
  str += "]";
  $('#divTitle').html(str);
}

function setNorder(norder){
  myGlobalVal.norder = norder;
  $("input#btnReflash").click();
}

function setSubtype(subtype){
  myGlobalVal.subtype = subtype;
  $("input#btnReflash").click();
}

function gen_now3(rdata){
  $('#div1006').html(crtTbl_2itmVrt( 21, "", "生肖", ["鼠","牛","虎","兔","龙","蛇","马","羊","猴","鸡","狗","猪"], rdata.r1006, rdata.r1006total ));
  $('#div1007').html(crtTbl_2itmVrt( 22, "", "尾数", ["1尾","2尾","3尾","4尾","5尾","6尾","7尾","8尾","9尾","10尾"], rdata.r1007, rdata.r1007total ));
  
  $('#div34').html(crtTbl_1itmVrt(34, "", "类别", ["总肖234","总肖 5","总肖 6","总肖 7"], rdata.r34, rdata.r34total ));
  $('#div35').html(crtTbl_1itmVrt(35, "", "类别", ["总肖单","总肖双"], rdata.r35, rdata.r35total ));
}


function gen_now5(rdata){
  var rArr = [7,8,9,10,11];
  var i, k, rObj, rObjTotal, iBet, str;
  if( myGlobalVal.subtype == 8 ){
    oObjTotal = eval('rdata.rspe' +  myGlobalVal.subtype + 'total' );
    $('#div5_n').html(crtTbl_1to49OnlyRate( myGlobalVal.subtype, 10, oObjTotal.rateArr));
    
    str = '';
    rObj = eval('rdata.rspe' + myGlobalVal.subtype);
    for(k = 0; k < rObj.length; k++){
      str += "<tr align=center ><td nowrap style='border-color:#FFFFFF'><a href='#'>" + rObj[k].numbers + '</a></td><td nowrap align=right style="color:#0000A8;border-color:#FFFFFF"><b>' + rObj[k].totalnum + "</b></td></tr>";
    }
    if(k > 0){
      str = '<table align="left">' + str + '</table>';
      $('#div5tbl_n').html(str);
    }
  
  }else{
    for(i = 0; i < 5; i++){
      str = '';
      iBet = rArr[i]; 
      rObj = eval('rdata.rspe' + iBet);
      rObjTotal = eval('rdata.rspe' + iBet +  'total');
      $('#rTotalG_' + iBet).html( '<a href="#">' +  rObjTotal.amount + '</a>');
      for(k = 0; k < rObj.length; k++){
        str += "<tr align=center ><td nowrap style='border-color:#FFFFFF'><a href='#'>" + rObj[k].numbers + '</a></td><td nowrap align=right style="color:#0000A8;border-color:#FFFFFF"><b>' + rObj[k].totalnum + "</b></td></tr>";
      }
      if(k > 0){
        str = '<table width="90%" >' + str + '</table>';
        $('#rNumG_' + iBet).html(str);
      }
      // show rate
      if(iBet == 11 || iBet == 7 ){
        $('#rRate' + iBet + '_1').text(rObjTotal.rateArr[0]);
      }else if(iBet == 9){
        $('#rRate9_1').text(rObjTotal.rateArr[0]);
        $('#rRate9_2').text(rObjTotal.rateArr[1]);
        $('#rRate33_1').text(rObjTotal.rateArr[2]);
        $('#rRate33_2').text(rObjTotal.rateArr[3]);
      }else if(iBet == 10){
        $('#rRate10_1').text(rObjTotal.rateArr[0]);
        $('#rRate10_2').text(rObjTotal.rateArr[1]);
        $('#rRate32_1').text(rObjTotal.rateArr[2]);
        $('#rRate32_2').text(rObjTotal.rateArr[3]);
      
      }else{
        $('#rRate' + iBet + '_1').text(rObjTotal.rateArr[0]);
        $('#rRate' + iBet + '_2').text(rObjTotal.rateArr[1]);
      }
    }
  }
}

function gen_now8(rdata){
 var str = '';
 var stitle = [[29, '五不中'],[39, '六不中'],[40, '七不中'],[41, '八不中'],[42, '九不中'],[43, '十不中'],[44, '十一不中'],[45, '十二不中']];
 var l = 8;
 var i, k, cls, oObj, oObjTotal;
 var sTitArr = new Array();
 var sTitle = '';
 var stdArr = new Array();
 
 str = '';
 for(i = 0; i < 8; i++){
    if( stitle[i][0] == myGlobalVal.subtype ){ cls = 'td2'; sTitle = stitle[i][1];}
    else{ cls = ''; } 
    sTitArr.push('&nbsp;<a href="javascript:setSubtype(' + stitle[i][0] + ');" class="' + cls + '" style="padding:5px;border-right:#cfcfff 1px solid">' + stitle[i][1] + '(0)</a>&nbsp;');
 }
 $('#divTitle').html( sTitArr.join(" "));
  
  oObjTotal = eval('rdata.rspe' +  myGlobalVal.subtype + 'total' );
                          
  str = crtTbl_1to49OnlyRate( myGlobalVal.subtype, 10, oObjTotal.rateArr);
  
  $('#div29to45').html(str);
  
  oObj = eval('rdata.rspe' +  myGlobalVal.subtype );
  
  k = 0;
  std = '';
  for(i = 0; i < oObj.length; i++){
    if(i == 0){ std += '<td><table width="150">'; }
    else if( i % 20 == 0){ std += '</table></td><td><table width="150">'; }
    std += '<tr><td nowrap align=center><a href="#">' + oObj[i].numbers + '</a></td><td nowrap align=right><font color=#0000A8><b>' + oObj[i].totalnum + '</b></font></td></tr>';
    
  }
  std += '</table></td>';
  str = '<div class="bgImg_0" style="font-size:16px;text-align:center;font-weight:bold">' + sTitle + ' Top 200</div>';
  if(i > 0){  str += '<table width="100%"><tr>' + std + '</tr></table>'; }
  str += '<br /><div class="td6">&nbsp;&nbsp;显示排行前 <b>' +  oObjTotal.totalnum + '</b> 笔，合计金额： <b>' + oObjTotal.amount + '</b></div>';
  $('#div29to45List').html( str);
  
}
function gen_now6(rdata){
  var dataListArr = [rdata.rspe27_2, rdata.rspe27_3, rdata.rspe27_4, rdata.rspe27_5];
  var dataListTotalArr = [rdata.rspe27_2total, rdata.rspe27_3total, rdata.rspe27_4total, rdata.rspe27_5total];
  var dataIdArr = [2,3,4,5];
  
  var i, j, k, idx, obj, objtotal, chArr, numArr;
  var str = '';
  var tr1 = '';
  
  var ch = ["", "鼠","牛","虎","兔","龙","蛇","马","羊","猴","鸡","狗","猪"];
  for(i = 0; i < 4; i++){
    idx = dataIdArr[i];
    obj = dataListArr[i];
    objtotal = dataListTotalArr[i];   
    
    $("#amu27_" + idx ).text(objtotal.amount);
    
    tr1 = '';
    for(k = 0; k < obj.length; k++){
      chArr = obj[k].numbers.split(',');
      numArr = [];
      for(j = 0; j < chArr.length; j++){
        chArr[j] = chArr[j] - 0;
        numArr.push(ch[chArr[j]]);
      } 
      tr1 += '<tr align=center><td nowrap style="border-color:#fff"><a href="#">' + numArr.join(',') + '</a></td><td nowrap align=right style="border-color:#fff"><font color=#0000A8><b>' + obj[k].amount + '</b></font></td></tr>';
    }
    
    str = '<table width="92%">' + tr1 + '</table>';
    $("#tblList27_" + idx ).html(str);
  }
}

function gen_now7(rdata){ 
  var dataListArr = [rdata.rspe36_21, rdata.rspe36_31, rdata.rspe36_41, rdata.rspe36_22, rdata.rspe36_32, rdata.rspe36_42];
  var dataListTotalArr = [rdata.rspe36_21total, rdata.rspe36_31total, rdata.rspe36_41total, rdata.rspe36_22total, rdata.rspe36_32total, rdata.rspe36_42total];
  var dataIdArr = [21,31,41,22,32,42];
  
  var i, k, idx, obj, objtotal;
  var str = '';
  var tr1 = '';
  
  for(i = 0; i < 6; i++){
    idx = dataIdArr[i];
    obj = dataListArr[i];
    objtotal = dataListTotalArr[i];   
    
    $("#amu36_" + idx ).text(objtotal.amount);
    
    tr1 = '';
    for(k = 0; k < obj.length; k++){
      tr1 += '<tr align=center><td nowrap style="border-color:#fff"><a href="#">' + obj[k].numbers + '</a></td><td nowrap align=right style="border-color:#fff"><font color=#0000A8><b>' + obj[k].amount + '</b></font></td></tr>';
    }
    
    str = '<table width="92%" border="0" width="92%" cellspacing="0" cellpadding="0">' + tr1 + '</table>';
    $("#tblList36_" + idx ).html(str);
  }
}
function gen_now9(rdata){
  $('#div9991').html(crtTbl_1to49( 9991, 1, rdata.r9991, rdata.r9991total ));
}

// -----------------------------------------------------------------------------
// 按了玩法执行结果
// -----------------------------------------------------------------------------
function clickTitle(playtype, slc, subtype){
 $("#myDivNow").empty();
 $("#myDivTbl").empty();
 myGlobalVal.playtypestr = playtype;
 myGlobalVal.slc = slc;
 myGlobalVal.norder = 1;
 if(subtype < 0){ myGlobalVal.subtype = 1; }
 else{ myGlobalVal.subtype = subtype; }
 myGlobalVal.addRate = 0.001;
 var str = "";
 
 // print the default table
 switch(playtype){
    case 'now1': 
      str = "<div id='div0'></div>";
      str += "<table width='1000' border='0' cellpadding='5' cellspacing='0'>";
      str += "<tr>";
      str += "<td><div id='div0Quick'>" + crt_divBtnQuick(0) + "</div></td>";
      str += "<td><div id='div0AddVal'>" + crt_divBtnAddVal(0, 1, 'A') + "</div></td>";
      str += "</tr>";
      str += "</table>";
      
      str += "<div id='div0btn'></div>";
      str += "<table width='990'><tr><td><div id='div1'></div></td><td><div id='div2'></div></td><td><div id='div3'></div></td><td><div id='div47'></div></td></tr></table>";
      
      str += "<table width='990'><tr><td><div id='div28'></div></td><td><div id='div30'></div></td><td><div id='div20'></div></td></tr></table>";
      str += "<table width='990'><tr><td><div id='div18'></div></td><td><div id='div14'></div></td></tr></table>";
      str += "<table width='990'><tr><td><div id='div13'></div></td><td><div id='div46'></div></td></tr></table>";
      $('#myDivTbl').html(str);
      break;
      
    case 'now1_1': 
      str = "<table width=800 border=0 cellpadding=5 cellspacing=0><tr valign=top cellpadding=5><td><div id=div19_01></div></td><td><div id=div19_02></div></td><td><div id=div19_03></div></td><td><div id=div19_04></div></td></tr><tr valign=top cellpadding=5><td><div id=div19_05></div></td><td><div id=div19_06></div></td><td><div id=div19_07></div></td><td><div id=div19_08></div></td></tr><tr valign=top cellpadding=5><td><div id=div19_09></div></td><td><div id=div19_10></div></td><td><div id=div19_11></div></td><td></td></tr></table>";
      str += "<br /><div id='div0AddVal'>" + crt_divBtnAddVal(0, 0, '') + "</div>";
      
      $('#myDivTbl').html(str);
      break;
      
    case 'now2':
      str = "<div id=div1002></div>";
      str += "<table width='990' border=0 cellpadding=3 cellspacing=3><tr valign=top cellpadding=3>";
      str += "<td cellspacing=3><div id='div0Quick'>" + crt_divBtnQuick(0) + "</div><br /></td>";
      str += "<td><br /><div id='div0AddVal' align='center'>" + crt_divBtnAddVal(2,1,'B') + "</div></td>";
      str += "</tr></table>";
      //str += "<br /><div id='div0AddVal' align='center'>" + crt_divBtnAddVal(0,1,'B') + "</div>";
      str += "<table width='990' border=0 cellpadding=3 cellspacing=0><tr valign=top cellpadding=3><td width='18%'><div id=div5></div></td><td width='40%'><div id=div15></div></td><td width='40%'><div id=div16></div></td></tr></table>";
      str += "<table width='990' border=0 cellpadding=3 cellspacing=0><tr valign=top cellpadding=3><td width='18%'><div id=div6></div></td><td width='50%'><div id=div17></div></td><td width='30%'><div id=div23></div></td></tr></table>";
      
      $('#myDivTbl').html(str);
    
      break;
      
    case 'now4':
      str = "<div id='divTitle'></div><div id='div1003'></div>";
      str += "<table width='1000' border=0 cellpadding=5 cellspacing=0>";
      str += "<tr>";
      str += "<td><div id='div0Quick'>" + crt_divBtnQuick(0) + "</div></td>";
      str += "<td><div id='div0AddVal'>" + crt_divBtnAddVal(0,1,'C') + "</div></td>";
      str += "</tr>";
      str += "</table>";
      $('#myDivTbl').html(str);
      break;
      
    case 'now3':
      str  = "<table width='800' border=0 cellpadding=5 cellspacing=0><tr valign=top cellpadding=5><td><div id=div1006></div></td><td></td><td><div id=div1007></div></td></tr></table>";
      str += "<table width='700' border=0 cellpadding=5 cellspacing=0><tr valign=top cellpadding=5><td><div id=div34></div></td><td></td><td><div id=div35></div></td></tr></table>";
      str += "<br /><div id='div0AddVal'>" + crt_divBtnAddVal(0,0,'') + "</div>";
      $('#myDivTbl').html(str);
      
      break;
      
    case 'now5':
      var sTltArr = [ ['三全中', [8,'最高','最低']], ['三中二', [9,'中二A','中三A'], [33, '中二B', '中三B']]
                    , ['二全中', [7,'二全中']], ['二中特',[10, '中特A','中二A'], [32, '中特B', '中二B']]
                    , ['特串',[11,'特串']] ];
      var i, j, k, so, colstr;
      var tr1 = "";
      var tr2 = "";
      var tr3 = "";
      var tr4 = "";
      
      if( myGlobalVal.subtype == 8){
        var cls = "";
        for(i = 0; i < sTltArr.length; i++){
          so = sTltArr[i];
          if(so[1][0] == myGlobalVal.subtype){
            cls = " class='td2''";  
          }else{
            cls = " class='td0'";
          }
          tr1 += "<td " + cls + "><a href='javascript:clickTitle(\"now5\", " + myGlobalVal.slc + ", " + so[1][0] + ");'>" + so[0] + "</a></td>";
          tr3 += "<td id='rTotalG_" + so[1][0] + "' style='border-color:#6A99A6' >0</td>";
           
        }
        
        str = "<table class='tblMy6H' width='990'>";
        str += "<tr class='bgImg_0' style='color:#007C00;background-color:#E7EBEF;text-align:center;'>" + tr1 + "</tr>";
        str += "<tr style='color:#007C00;background-color:#FCFCD8;text-align:center;'>" + tr3 + "</tr>";
        str += "<tr style='background-color:#C0D6EB;text-align:center;font-weight:bold;'><td colspan='" + sTltArr.length + "' class='td15' style='font-size:14px;'>三全中 49号各别操盘</td></tr>";
        str += "<tr style='color:#000000;background-color:#FFFFFF;text-align:center;'><td colspan='" + sTltArr.length + "' class='td2'  style='text-align:center'><div id='div5_n'></div></td></tr>";
        str += "<tr><td colspan='" + (sTltArr.length - 2) + "' class='td2'><div id='div0Quick'>" + crt_divBtnQuick(0) + "</div></td>";
        str += "<td colspan='2' class='td2'><br /><div id='div0AddVal'>" + crt_divBtnAddVal(1,1, 'E') + "</div></td>";
        str += "</tr>";
        
      
        str += "<tr style='background-color:#C0D6EB;text-align:center;font-weight:bold;'><td colspan='" + sTltArr.length + "' class='td15' style='font-size:14px;'>三全中 TOP 180</td></tr>";
        str += "<tr style='color:#000000;background-color:#FFFFFF;text-align:center;'><td colspan='" + sTltArr.length + "' class='td2'  style='text-align:center'><div id='div5tbl_n'></div></td></tr>";
        str += "</table>";
        myGlobalVal.addRate = 1;
      
      }else{
        for(i = 0; i < sTltArr.length; i++){
          so = sTltArr[i];
          if( so.length > 2){ colstr = " colspan='2' ";}
          else{ colstr = ""; }
          //  style='border-color:#6A99A6'
          tr1 += "<td" + colstr + " style='border-color:#6A99A6'><a href='javascript:clickTitle(\"now5\", " + myGlobalVal.slc + ", " + so[1][0] + ");'>" + so[0] + "</a></td>";
          tr3 += "<td" + colstr + " id='rTotalG_" + so[1][0] + "' style='border-color:#6A99A6' >0</td>"; 
          tr4 += "<td" + colstr + " id='rNumG_" + so[1][0] + "' valign=top align=center style='border-color:#6A99A6'></td>";
          
          for( j = 1; j < so.length; j++){
            tr2 += "<td style='border-color:#6A99A6'>"
            for( k = 1; k < so[j].length; k++){
              tr2 += so[j][k] + " <span class='rate' id='rRate" + so[j][0] + "_" + k + "'>0</span><br />";
              if( i == 0 && k == 1){ continue; }
              tr2 += "<input type=button onclick='ratediffChg(" + so[j][0] + ", 0, \"0" + k + "\", -1);' value=- class=btnmin> <input type=button onclick='ratediffChg(" + so[j][0] + ", 0, \"0" + k + "\", 1);' value=+ class=btnplus><br />";
            }                                    
            tr2 += "</td>";
          }
        }
        
        str = "<table class='tblMy6H' width='990'>";
        str += "<tr style='background-color:#C0D6EB;text-align:center;'>" + tr1 + "</tr>";
        str += "<tr style='color:#007C00;background-color:#E7EBEF;text-align:center;'>" + tr2 + "</tr>";
        str += "<tr style='color:#007C00;background-color:#FCFCD8;text-align:center;'>" + tr3 + "</tr>";
        str += "<tr style='color:#000000;background-color:#FFFFFF;text-align:center;'>" + tr4 + "</tr>";
      }
        
      $('#myDivTbl').html(str);
      break;
      
    case 'now8':
      myGlobalVal.subtype = 29;
      str = "<div id='divTitle' class='title0' style='width:990px;padding-top:5px;padding-bottom:5px;background-color:#dff9ff'></div><div id='div29to45'></div>";
      str += "<table width='1000' border=0 cellpadding=5 cellspacing=0>";
      str += "<tr>";
      str += "<td><div id='div0Quick'>" + crt_divBtnQuick(0) + "</div></td>";
      str += "<td><div id='div0AddVal'>" + crt_divBtnAddVal(0,1, 'D') + "</div></td>";
      str += "</tr>";
      str += "</table>";
      str += "<br /><div id='div29to45List' class='title0' style='width:990px;background-color:#fff;'></div>";
      $('#myDivTbl').html(str);
      break;
    case 'now6':
      var td1Arr = [[2, '二肖'],[3, '三肖'],[4, '四肖'],[5, '五肖']];
      var trArr = ["","","",""];
      // style='border-color:#6A99A6'
      for(var i = 0; i < 4; i++){
        trArr[0] += "<td style='border-color:#6A99A6'>" + td1Arr[i][1] + "</td>";
        trArr[1] += "<td style='border-color:#6A99A6'><input type='button' value='操盘' class='btnchoiced' onclick='javascript:showRateTbl(27, " + td1Arr[i][0] + ");' /></td>";
        trArr[2] += "<td style='border-color:#6A99A6'><a href='#' id='amu27_" + td1Arr[i][0] + "'>0</a></td>";
        trArr[3] += "<td style='border-color:#6A99A6' id='tblList27_" + td1Arr[i][0] + "'>&nbsp;</td>";
      }
      
      str = '';
      str +="<div id='divRatePanel'></div>";
      str += "<table class='tblMy6H' width='580' style='border-color:#6A99A6'>";
      str += "<tr bgcolor='#C0D6EB' align='center'>" + trArr[0] + "</tr>";
      str += "<tr align='center' bgcolor='#e7ebef' height='28'>" + trArr[1] + "</tr>";
      str += "<tr align='center' bgcolor='#FCFCD8'>" + trArr[2] + "</tr>";
      str += "<tr valign='top' align='center' bgcolor='#FFFFFF'>" + trArr[3] + "</tr>";
      str += "</table>";
      $('#myDivTbl').html(str);
      break;
    case 'now7':
      var td1Arr =[[21,'二尾 中'], [31,'三尾 中'], [41,'四尾 中'], [22,'二尾不中'], [32,'三尾不中'], [42,'四尾不中'] ];
      var trArr = ["","","","","",""];
      // style='border-color:#6A99A6'
      for(var i = 0; i < 6; i++){
        trArr[0] += "<td style='border-color:#6A99A6'>" + td1Arr[i][1] + "</td>";
        trArr[1] += "<td style='border-color:#6A99A6'><input type='button' value='操盘' class='btnchoiced' onclick='javascript:showRateTbl(36, " + td1Arr[i][0] + ");' /></td>";
        trArr[2] += "<td style='border-color:#6A99A6'><a href='#' id='amu36_" + td1Arr[i][0] + "'>0</a></td>";
        trArr[3] += "<td style='border-color:#6A99A6' id='tblList36_" + td1Arr[i][0] + "'>-</td>";
      }
      
      str = '';
      str +="<div id='divRatePanel'></div>";
      str += "<table class='tblMy6H' width='780' style='border-color:#6A99A6'>";
      str += "<tr bgcolor='#C0D6EB' align='center'>" + trArr[0] + "</tr>";
      str += "<tr align='center' bgcolor='#e7ebef' height='28'>" + trArr[1] + "</tr>";
      str += "<tr align='center' bgcolor='#FCFCD8'>" + trArr[2] + "</tr>";
      str += "<tr valign='top' align='center' bgcolor='#FFFFFF'>" + trArr[3] + "</tr>";
      str += "</table>";
      $('#myDivTbl').html(str);
      break;
      
    case 'now9':
      str = "<div id='div9991'></div>";
      str += "<table width='1000' border='0' cellpadding='5' cellspacing='0'><tr>";
      str += "<td><br /><div id='div0Quick'>" + crt_divBtnQuick(0) + "</div></td>";
      str += "<td><br /><div id='div0AddVal'>" + crt_divBtnAddVal(0,1, 'A') + "</div></td>";
      str += "</tr></table>";
      str += "<br /><b>※ 整合：特码ＡＢ，单双大小，特尾大小，合单双，合尾大小，家禽野兽，生肖、色波及半波的预估输赢结果（不包含合肖）</b>";
      str += "<br /><b>※ 操盘仅异动 [特码ＡＢ] 之赔率</b>";
      $('#myDivTbl').html(str);
      break;
    default: $("#myDivNow").html('error!'); return ; break;
 }
 
 $("input#btnReflash").click();
 
 
}

// -----------------------------------------------------------------------------
// for now page
// -----------------------------------------------------------------------------

$(function(){
       
  
  clickTitle(myGlobalVal.playtypestr, myGlobalVal.slc , -1);
  
  $("#split").change(function(){
    $("input#btnReflash").click();
  });
  $("#norder").change(function(){
    $("input#btnReflash").click();
  });

  $("#slcCidChg").change(function(){
    var valArr = $(this).val().split('_');
    myGlobalVal.cid = valArr[0];
    myGlobalVal.lotto_id = valArr[1];
    if(  myGlobalVal.lotto_idArr[myGlobalVal.cid] != myGlobalVal.lotto_id ){
      alert('期数错误,请按[F5]重新整理后再尝试!');
      return false;
    }
    else
    {
      $("input#btnReflash").click();
      return true;
    }  
  });
  
  // raterecord -- over page
  $("#btnRateRecord").click(function(){
    showRateRecordPageCid(myGlobalVal.gametype, myGlobalVal.open, myGlobalVal.cid);  
  });  

  
});